﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using static AD.Pms.Api.Entities.Enums.CommonEnum;
using System.ComponentModel.DataAnnotations.Schema;

namespace AD.Pms.Api.Entities
{
    /// <summary>
    /// 
    /// </summary>
    [Table("tbl_SysUser")]
    public class User
    {
        /// <summary>
        /// 用户GUID
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public Guid UserID { get; set; }

        /// <summary>
        /// 电话号码
        /// </summary>
        [Required]
        public string Phone { get; set; }

        /// <summary>
        /// 显示名称
        /// </summary>
        public string DisplayName { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        public UserType UserType { get; set; }

        /// <summary>
        /// 锁定状态
        /// </summary>
        public IsLocked IsLocked { get; set; }

        /// <summary>
        /// 用户状态
        /// </summary>
        public UserStatus Status { get; set; }

        /// <summary>
        /// 删除标识
        /// </summary>
        public bool IsDelete { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 创建者ID
        /// </summary>
        public Guid CreateBy { get; set; }

        /// <summary>
        /// 最近修改时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 最近修改者ID
        /// </summary>
        public Guid? UpdateBy { get; set; }

        /// <summary>
        /// 用户描述信息
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 用户的角色集合
        /// </summary>
        public ICollection<UserRoleMapping> UserRoles { get; set; }
    }

    /// <summary>
    /// 用户类型
    /// </summary>
    public enum UserType
    {
        /// <summary>
        /// 超级管理员
        /// </summary>
        SuperAdministrator = 0,

        /// <summary>
        /// 管理员
        /// </summary>
        Admin = 1,

        /// <summary>
        /// 一般用户
        /// </summary>
        GeneralUser = 2
    }

    /// <summary>
    /// 用户状态
    /// </summary>
    public enum UserStatus
    {
        /// <summary>
        /// 未指定
        /// </summary>
        All = -1,

        /// <summary>
        /// 已禁用
        /// </summary>
        Forbidden = 0,

        /// <summary>
        /// 正常
        /// </summary>
        Normal = 1
    }
}
